package cn.tannn.surenessdemo.controller;

import cn.jdevelops.annotation.mapping.PathRestController;
import cn.jdevelops.result.result.ResultVO;
import cn.jdevelops.springs.service.url.UrlService;
import cn.jdevelops.springs.service.url.entity.Urls;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 工具接口
 *
 * @author tnnn
 * @version V1.0
 * @date 2022-07-20 09:08
 */
@PathRestController("url")
@Slf4j
@Api(tags = "工具接口", value = "工具接口")
@RequiredArgsConstructor
@ApiSupport(order = 6)
public class UrlController {

    private final UrlService urlService;

    @ApiOperation(value = "获取所有的接口", notes = "工具接口")
    @GetMapping("/getAll")
    public ResultVO<Map<String, List<Urls>>> getAllUrl(){
        List<Urls> localUrl = urlService.getLocalUrl();
        List<Urls> resultUrl = localUrl.stream().distinct().collect(Collectors.toList());
        Map<String, List<Urls>> resultUrlMap = resultUrl.stream().collect(Collectors.groupingBy(Urls::getGrouping));
        return ResultVO.success(resultUrlMap,"接口总数："+resultUrl.size());
    }




}
